package logic

import (
	"context"
	"zhihu/zhihurpc/zhihurpcclient"

	"zhihu/zhihuapi/internal/svc"
	"zhihu/zhihuapi/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type ProblemHotLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewProblemHotLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ProblemHotLogic {
	return &ProblemHotLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *ProblemHotLogic) ProblemHot(req *types.ProblemHotRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	hot, err := l.svcCtx.ZhiHuRpc.ProblemHot(l.ctx, &zhihurpcclient.ProblemHotRequest{})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Data:    nil,
			Code:    500,
		}, nil
	}
	return &types.Response{
		Message: "TOP10问题列表访问成功",
		Data:    hot,
		Code:    200,
	}, nil
}
